﻿<%@ Page Title="" Language="C#" MasterPageFile="~/module/Fontend.Master" AutoEventWireup="true"
    CodeBehind="ArticleDetails.aspx.cs" Inherits="mamnontuoitho7.module.ArticleDetails" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <script language="javascript" type="text/javascript">

        function ClientComment_Click() {

            var commentContent = trim(document.getElementById("<%= txtComment.ClientID %>").value);

            if (commentContent.length < 10) {
                alert("Cần gõ hơn 10 ký tự");
                return false;
            }
        }
        function trim(str) {
            return str.replace(/^\s+|\s+$/g, "");
        }
    </script>
    <div class="green">
        Trang chủ &raquo; Sức khỏe &raquo;
        <%= _general.ReplaceSpecialCharacters(_dt.Rows[0]["Title"].ToString())%></div>
    <div class="articlescontent">
        <div class="underline">
            <table>
                <tr>
                    <td>
                        <h2>
                            <span class="postnews">Cập nhật ngày:
                                <%= DateTime.Parse(_dt.Rows[0]["PostDate"].ToString()).ToString("dd/MM/yyyy HH:mm:ss")%></span>
                            <span class="view">Lượt xem:
                                <%=_dt.Rows[0]["ViewNumber"].ToString() %></span> <span class="comment">Bình luận:
                                    <%= _comment.TotalCommentOfOneProduct(_dt.Rows[0]["ProductID"].ToString()).GetValueOrDefault() %></span>
                       </h2>
                    </td>
                    <td width="150px">
                    </td>
                </tr>
            </table>
        </div>
        <div>
            <%=_dt.Rows[0]["Content"].ToString() %></div>
    </div>
    <div class="articlemore">
        <h1 class="h1_green">
            Bài viết liên quan:</h1>
        <%
            for (int i = 0; i < _dtLink.Rows.Count; i++)
            {
                if (_dtLink.Rows[i]["ProductID"].ToString()!=_productID)
                {
        %>
        <div class="articlemore-link">
            <a href="ArticleDetails.aspx?ArticleID=<%= _dtLink.Rows[i]["ProductID"].ToString()%>">
                <%= _general.ReplaceSpecialCharacters(_dtLink.Rows[i]["Title"].ToString())%><span> (<%= DateTime.Parse(_dtLink.Rows[i]["PostDate"].ToString()).ToString("dd/MM/yyyy")%>)</span></a></div>
        <% }
         } %>
    </div>

    <form id="form1" runat="server">
        <div class="articlemore">
            <h1 class="h1_green">Bình luận bài viết:</h1>
            <div class="articlecomment">
                <asp:TextBox TextMode="MultiLine" ID="txtComment" runat="server"></asp:TextBox>
                <% if (Session["username"] != "")
                   { %>
                <asp:Button ID="btnPostComment" runat="server" CssClass="buttons" Text="Bình luận"
                    OnClick="btnPostComment_Click" OnClientClick="return ClientComment_Click()" />
                <% }
                   else
                   {%>
                <a href="#loginform" onclick="showhide('loginform');" class="buttons">Đăng nhập</a>
                <%} %>
            </div>
        </div>
    </form>

    <%
        int _commentAmount = _dtComment.Rows.Count;
      %>  

      <input type="hidden" id="hihCommentAmount" value="<%= _commentAmount%>" />
    <%    
        for (int i = 0; i < _commentAmount; i++)
        {
    %>
    <div class="commentdetail">
        <img src="../images/avatar/teacher_parents/aa.jpg" alt="" />
        <span class="arrow"><span></span></span>


        <div id="showcontent<%= i%>" class="blockcontent">
            <div class="content">
                <%= _dtComment.Rows[i]["ContentComment"].ToString()%>
            </div>
            <div class="info">
                bởi <a href="#">
                    <%= _dtComment.Rows[i]["FullName"].ToString()%></a> lúc:
                <%= DateTime.Parse(_dtComment.Rows[i]["CreateDate"].ToString()).ToString("dd/MM/yyyy HH:mm:ss")%>
                 <% if (_comment.checkCommentOwner(Session["username"].ToString(), _dtComment.Rows[i]["CommentID"].ToString()))
                   { %>
                <a href="#editcontent" onclick="hide('showcontent<%= i%>'); showhide('editcontent<%= i%>');" class="buttonlink">Sửa</a>
                <%} %>
             </div>
        </div>
        <div id="editcontent<%= i%>" class="blockcontent">
            <div class="content">
                <textarea id="txtNewComment" name="txtNewComment" class="textarea"><%= _dtComment.Rows[i]["ContentComment"].ToString()%></textarea>
            </div>
            <div class="info">
                bởi <a href="#">
                    <%= _dtComment.Rows[i]["FullName"].ToString()%></a> lúc:
                <%= DateTime.Parse(_dtComment.Rows[i]["CreateDate"].ToString()).ToString("dd/MM/yyyy HH:mm:ss")%>
                <a href="#showcontent" onclick="hide('editcontent<%= i%>'); showhide('showcontent<%= i%>');" class="buttonlink">Hủy</a>
                <input type="button" value="Cập nhật" class="buttoncomment" /></div>
        </div>
    </div>
    <% }%>
    <div id="container">
        <div class="pagination">
            <%if (_currentbar > 1)
              { %>
            <a href="ArticleDetails.aspx?a=-1" class="pagegreen"><<</a>
            <%} %>
            <%  

                for (int j = _beginPage; j <= _endPage; j++)
                {
                    if (j == _pageflag)
                    {
            
            %>
            <a href="ArticleDetails.aspx?page=<%= j%>" class="pagegreen active">
                <%= j%></a>
            <% }
                    else
                    { %>
            <a href="ArticleDetails.aspx?page=<%= j%>" class="pagegreen">
                <%= j%></a>
            <%  }
                } %>
            <%if (_currentbar < _totalBars)
              { %>
            <a href="ArticleDetails.aspx?a=1" class="pagegreen">>></a>
            <%} %>
            <%-- <a href="#" class="pagegreen"><<</a>
                <a href="#" class="pagegreen">2</a>
                <a href="#" class="pagegreen">3</a>
                <span class="pagegreen active">4</span>
                <a href="#" class="pagegreen">5</a>
                <a href="#" class="pagegreen">6</a>
                <a href="#"class="pagegreen">>></a>--%>
        </div>
    </div>
</asp:Content>
